Skip to content

Conversation

@DhruvArvindSingh
Copy link
Contributor

Progresses #2039.

Description

What is the purpose of this pull request?

This pull request:

  • Adds JS implementation of @stdlib/blas/base/drotmg
  • Adds Fortran implementation of @stdlib/blas/base/drotmg
  • Adds C implementation of @stdlib/blas/base/drotmg
  • Adds Tests , Benchmarks and Examples for C, Fortran and JS

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

  • In this PR i have implemented drotmg main and assign function in C with 6 and 7 arguments respectively
void c_drotmg( const double d1, const double d2, const double x1, const double y1, double *Out, const CBLAS_INT strideOut );
void c_drotmg_assign( const double d1, const double d2, const double x1, const double y1, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut );
  • In this PR i have implemented drotmg.f code by taking reference from LAPACK LINK
void drotmg( double *, double *, double *, const double *, double * );

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

{{TODO: add disclosure if applicable}}


@stdlib-js/reviewers

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: passed
  - task: lint_package_json
    status: passed
  - task: lint_repl_help
    status: passed
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: passed
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: missing_dependencies
  - task: lint_c_examples
    status: missing_dependencies
  - task: lint_c_benchmarks
    status: missing_dependencies
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: passed
  - task: lint_license_headers
    status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@stdlib-bot stdlib-bot added BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). Needs Review A pull request which needs code review. labels Jan 13, 2026
@DhruvArvindSingh DhruvArvindSingh changed the title Feat/drotmg feat: add blas/base/drotmg Jan 13, 2026
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jan 13, 2026

Coverage Report

Package Statements Branches Functions Lines
blas/base/drotmg $\color{red}449/497$
$\color{green}+0.00%$
$\color{red}31/34$
$\color{green}+0.00%$
$\color{green}4/4$
$\color{green}+0.00%$
$\color{red}449/497$
$\color{green}+0.00%$

The above coverage report was generated for the changes in this PR.

Copy link
Member

@Planeshifter Planeshifter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some initial comments.

// MODULES //

var abs = require( '@stdlib/math/base/special/abs' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a double-precision function (drotmg), so we should use is-nan instead of is-nanf. The f variant is for single-precision floats.

Suggested change
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );

And then update the usage on line 69 to use isnan instead of isnanf.

Comment on lines +100 to +109
if ( ad1 > ad2 ) {
h21 = -y1 / x1;
h12 = p2 / p1;
u = 1 - ( h12 * h21 );
if ( u > 0.0 ) {
flag = 0.0;
d1 = d1 / u;
d2 = d2 / u;
x1 = x1 * u;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code tells me that this is missing handling for the u <= 0 edge case in this branch and that the Fortran reference implementation (lines 113-126) handles this by setting flag = -1, zeroing out all h values, and zeroing d1, d2, x1. Can you please cross-check the JS implementation against the Fortran code?

Comment on lines +83 to +92
if ( ad1 > ad2 ) {
h21 = -y1 / x1;
h12 = p2 / p1;
u = 1.0 - ( h12 * h21 );
if ( u > 0.0 ) {
flag = 0.0;
d1 = d1 / u;
d2 = d2 / u;
x1 = x1 * u;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as in the JavaScript implementation for whether handling for the u <= 0 edge case is missing.

Comment on lines +22 to +23
#ifndef STDLIB_BLAS_EXT_BASE_DROTMG_H
#define STDLIB_BLAS_EXT_BASE_DROTMG_H
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The include guard uses STDLIB_BLAS_EXT_BASE_DROTMG_H but this package is in blas/base/ not blas/ext/base/. Should be STDLIB_BLAS_BASE_DROTMG_H to match other packages like drotm.

Suggested change
#ifndef STDLIB_BLAS_EXT_BASE_DROTMG_H
#define STDLIB_BLAS_EXT_BASE_DROTMG_H
#ifndef STDLIB_BLAS_BASE_DROTMG_H
#define STDLIB_BLAS_BASE_DROTMG_H

Also update line 48 to match.

Comment on lines +22 to +23
#ifndef STDLIB_BLAS_EXT_BASE_DROTMG_CBLAS_H
#define STDLIB_BLAS_EXT_BASE_DROTMG_CBLAS_H
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue - should use STDLIB_BLAS_BASE_DROTMG_CBLAS_H (no EXT).

Suggested change
#ifndef STDLIB_BLAS_EXT_BASE_DROTMG_CBLAS_H
#define STDLIB_BLAS_EXT_BASE_DROTMG_CBLAS_H
#ifndef STDLIB_BLAS_BASE_DROTMG_CBLAS_H
#define STDLIB_BLAS_BASE_DROTMG_CBLAS_H

Also update line 43 to match.

Comment on lines +22 to +23
#ifndef STDLIB_BLAS_EXT_BASE_DROTMG_FORTRAN_H
#define STDLIB_BLAS_EXT_BASE_DROTMG_FORTRAN_H
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue - should use STDLIB_BLAS_BASE_DROTMG_FORTRAN_H (no EXT).

Suggested change
#ifndef STDLIB_BLAS_EXT_BASE_DROTMG_FORTRAN_H
#define STDLIB_BLAS_EXT_BASE_DROTMG_FORTRAN_H
#ifndef STDLIB_BLAS_BASE_DROTMG_FORTRAN_H
#define STDLIB_BLAS_BASE_DROTMG_FORTRAN_H

Also update line 41 to match.

// TypeScript Version: 4.1

/**
* Inteface describing `drotmg`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo: "Inteface" should be "Interface".

Suggested change
* Inteface describing `drotmg`.
* Interface describing `drotmg`.

Comment on lines +68 to +78
/**
* Constructs the parameters for a modified Givens plane rotation.
*
* @param d1 - scaling factor for the first vector component
* @param d2 - scaling factor for the second vector component
* @param x1 - first component of the first vector
* @param y1 - first component of the second vector
* @param out - output array
* @param stride - index increment
* @param offset - starting index
* @returns - output array containing the rotation parameters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSDoc for this declaration includes parameters (out, stride, offset) that don't apply to the main function signature - those only apply to the assign method. The main signature is just ( d1, d2, x1, y1 ).

Should be:

/**
* Constructs the parameters for a modified Givens plane rotation.
*
* @param d1 - scaling factor for the first vector component
* @param d2 - scaling factor for the second vector component
* @param x1 - first component of the first vector
* @param y1 - first component of the second vector
* @returns - output array containing the rotation parameters
*
* @example

Comment on lines +59 to +64
var tmp = tryRequire(join(__dirname, './native.js'));
if (isError(tmp)) {
drotmg = main;
} else {
drotmg = tmp;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing spaces inside parentheses - stdlib style requires spaces inside function calls. Compare with drotm/lib/index.js:

Suggested change
var tmp = tryRequire(join(__dirname, './native.js'));
if (isError(tmp)) {
drotmg = main;
} else {
drotmg = tmp;
}
var tmp = tryRequire( join( __dirname, './native.js' ) );
if ( isError( tmp ) ) {
drotmg = main;
} else {
drotmg = tmp;
}

@Planeshifter Planeshifter added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). Needs Changes Pull request which needs changes before being merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants